// Magic Software, Inc.
// http://www.magic-software.com
// Copyright (c) 2000, All Rights Reserved
//
// Source code from Magic Software is supplied under the terms of a license
// agreement and may not be copied or disclosed except in accordance with the
// terms of that agreement.  The various license agreements may be found at
// the Magic Software web site.  This file is subject to the license
//
// RESTRICTED USE SOURCE CODE
// http://www.magic-software.com/License/restricted.pdf

#include "MgcAlphaState.h"

MgcImplementRTTI(MgcAlphaState,MgcRenderState);
MgcImplementStream(MgcAlphaState);
MgcImplementDefaultState(MgcAlphaState);

//----------------------------------------------------------------------------
MgcRenderState::Type MgcAlphaState::GetType () const
{
    return RS_ALPHA;
}
//----------------------------------------------------------------------------
MgcAlphaState::MgcAlphaState ()
{
    m_bBlendEnabled = false;
    m_eSrcBlend = SBF_SRC_ALPHA;
    m_eDstBlend = DBF_ONE_MINUS_SRC_ALPHA;
    m_bTestEnabled = false;
    m_eTest = TF_ALWAYS;
    m_fReference = 0.0;
}
//----------------------------------------------------------------------------

//---------------------------------------------------------------------------
// streaming
//---------------------------------------------------------------------------
MgcObject* MgcAlphaState::Factory (MgcStream& rkStream)
{
    MgcAlphaState* pkObject = new MgcAlphaState;
    MgcStream::Link* pkLink = new MgcStream::Link(pkObject);
    pkObject->Load(rkStream,pkLink);
    return pkObject;
}
//---------------------------------------------------------------------------
void MgcAlphaState::Load (MgcStream& rkStream, MgcStream::Link* pkLink)
{
    MgcRenderState::Load(rkStream,pkLink);

    // native data
    MgcStreamRead(rkStream,m_bBlendEnabled);
    MgcStreamRead(rkStream,m_eSrcBlend);
    MgcStreamRead(rkStream,m_eDstBlend);
    MgcStreamRead(rkStream,m_bTestEnabled);
    MgcStreamRead(rkStream,m_eTest);
    MgcStreamRead(rkStream,m_fReference);
}
//---------------------------------------------------------------------------
void MgcAlphaState::Link (MgcStream& rkStream, MgcStream::Link* pkLink)
{
    MgcRenderState::Link(rkStream,pkLink);
}
//---------------------------------------------------------------------------
bool MgcAlphaState::Register (MgcStream& rkStream)
{
    return MgcRenderState::Register(rkStream);
}
//---------------------------------------------------------------------------
void MgcAlphaState::Save (MgcStream& rkStream)
{
    MgcRenderState::Save(rkStream);

    // native data
    MgcStreamWrite(rkStream,m_bBlendEnabled);
    MgcStreamWrite(rkStream,m_eSrcBlend);
    MgcStreamWrite(rkStream,m_eDstBlend);
    MgcStreamWrite(rkStream,m_bTestEnabled);
    MgcStreamWrite(rkStream,m_eTest);
    MgcStreamWrite(rkStream,m_fReference);
}
//---------------------------------------------------------------------------
